# Maintainer: Peter Budai <peterbudai@hotmail.com>

_realname=ptyprocess
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.7.0
pkgrel=4
pkgdesc="Run a subprocess in a pseudo terminal (mingw-w64)"
url="https://github.com/pexpect/ptyprocess"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
license=('spdx:ISC')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=(${_realname}-${pkgver}.tar.gz::https://pypi.io/packages/source/p/${_realname}/${_realname}-${pkgver}.tar.gz
            https://raw.githubusercontent.com/pexpect/ptyprocess/${pkgver}/LICENSE)
sha256sums=('5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220'
            'c822d385b1a73329846241799becf18690b5d44764c1bed69300b536a405030a')

prepare() {
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd ${srcdir}/"python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --root=${pkgdir} --prefix=${MINGW_PREFIX} --optimize=1 --skip-build

  install -D -m644 "${srcdir}/LICENSE" ${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE
}
